<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
selection_test(
  '<span>^ab|</span><br><a href="#" tabindex="-1">CD</a>',
  selection => {
    if (!window.eventSender)
      throw 'This test requires eventSender.';
    const target = selection.document.querySelector('a');
    let gotMouseDown = false;
    target.addEventListener('mousedown', () => gotMouseDown = true);
    eventSender.mouseMoveTo(
        selection.computeLeft(target) + target.offsetWidth / 2,
        selection.computeTop(target) + target.offsetHeight / 2);
    eventSender.mouseDown();
    assert_true(gotMouseDown, 'Got mousedown on A element');
  },
  '<span>^ab|</span><br><a href="#" tabindex="-1">CD</a>',
  'mouse down should not clear selection');
</script>
